#ifndef _TIMERTHREAD_H_
#define _TIMERTHREAD_H_

#include "../define/define.h"
#include "log.h"
#include "lock.h"
#include "timer.h"
#include "bthread.h"

class TimeSink
{
public:
    virtual void OnTimer() = 0;
};

struct Sink_info
{
	uint32           second;
	uint32           count;
    TimeSink*        sink;
};

class  Timer_Thread : public bthread
{
public:
    Timer_Thread();
   ~Timer_Thread();

  	bool  add_sink(TimeSink* sink, uint32 ms_second);
	bool  delete_sink(TimeSink* sink);

	bool  add_time(uint32 time)
	{
		m_time = time;
	}
protected:

	void Execute();

private:

    uint32             m_time;
    vector<Sink_info>  m_sink;

	logfile*           m_log;
	lock               m_lock;	
};


bool add_sink(TimeSink* sink, uint32 ms_second);
bool del_sink(TimeSink* sink);
bool add_thread_time(uint32 time);



#endif
